package com.quiz.quazz.client;

public class Player implements Comparable<Player> {
	private String ip;

	private String name;

	private Integer points;

	public Player(String ip, String name) {
		setIp(ip);
		setName(name);
		setPoints(0);
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getPoints() {
		return points;
	}

	public void setPoints(Integer points) {
		this.points = points;
	}

	public void addPoints(Integer points) {
		this.points += points;
	}

	public void removePoints(Integer points) {
		this.points -= points;
	}

	@Override
	public int compareTo(Player another) {
		return this.getPoints() - another.getPoints();
	}

	@Override
	public int hashCode() {
		return 41 * this.ip.hashCode();
	}

	@Override
	public boolean equals(Object o) {
		return this.ip.equals(((Player) o).ip);
	}

	@Override
	public String toString() {
		return name + " " + ip;
	}
}
